package com.mdx.order.controller;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Component;
import com.rabbitmq.client.Channel;

/**
 * 添加任务的mq监听器 -- 主要是MDMS系统
 *
 * @author : jiagang
 * @date : Created in 2021/11/18 9:33
 */
@Component
@Slf4j
//@RabbitListener(bindings = @QueueBinding(
//        exchange = @Exchange("directExchange"), // 交换机(直连)
//        key = "addTaskRouting",                // 路由key
//        value = @Queue("consumerTest"))) //监听队列的名称
public class RabbitMqConsumerTest {


    @RabbitHandler
    public void process(@Payload Object messages, @Header(AmqpHeaders.DELIVERY_TAG) long deliveryTag, Channel channel) throws Exception {
        log.info("接收到mq的消息~");
        System.out.println(messages);
    }
}
